// 导入统一定义的type
import * as types from '../actionTypes/counter';

// 创建 store 需要一个 reducer
export const counter = (state = 10, action) => {
  // 改为 if/else 实现 reducer
  if (action.type === types.INCREMENT) {
    console.log('++');
    return state + action.payload;
  } else if (action.type === types.DECREMENT) {
    console.log('--');
    return state - action.payload;
  } else {
    return state;
  }
};
